#ifndef DMA_HPP
#define DMA_HPP
#include <stdint.h>
#include <stdbool.h>

#define HandleTPDF uint32_t
///> DMA 设备 类抽象
namespace device
{
	class dma
	{
		public:
			
			typedef void (*DmaCompleteDelegate)(void);
			
			typedef enum
			{
				DMA_DATA_TYPE_UINT8 = 0,
				DMA_DATA_TYPE_UINT16,
				DMA_DATA_TYPE_UINT32,
			}DmaDataTypeTPDF;
			
			typedef enum
			{
				DMA_TRANS_MODE_SFR_TO_MEM = 0,
				DMA_TRANS_MODE_SFRSQR_TO_MEM,
				DMA_TRANS_MODE_MEM_TO_SFR,
			}DmaTransModeTPDF;
			
			typedef struct
			{
				bool bCircularMode;
				DmaDataTypeTPDF tDmaDataType;
				DmaTransModeTPDF tDmaTransMode;
				uint16_t usSfrId;
				uint32_t uiSrc;
				uint32_t uiDest;
				DmaCompleteDelegate tDmaCompleteCallback;
			}DmaInitTPDF;
			
			static HandleTPDF Request(DmaInitTPDF *tDmaInit);
			static void StartDma(HandleTPDF tHandle, uint16_t ucLen);
			static void StartDmaFsrToMem(HandleTPDF tHandle, uint16_t ucLen, void* pMem);
			static void StartDma(HandleTPDF tHandle, uint16_t ucLen, uint16_t ucMemRptLen, uint16_t ucSfrPptLen, void* pMem);
			static uint32_t* GetLengthRegister(HandleTPDF tHandle);
			static void Reset(HandleTPDF tHandle, uint16_t ucLen, uint16_t ucMemRptLen, uint16_t ucSfrPptLen);
	};
}

#endif
